import request from '@/router/axios';

// 主订单列表查询
export const apiList = (current, size,params) => {
  return request({
    url: '/api/rb-oem/oem/mall/mallApi/queryMasterOrderList',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  })
}

/* 主订单列表统计 */
export const apiStatistics = (params) => {
  return request({
    url: '/api/rb-oem/oem/mall/mallApi/masterOrderStatistics',
    method: 'get',
    params
  })
}

/* 主订单导出 */
export const apiExport = (params) => {
  return request({
    headers: {
      "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
    },
    responseType: 'blob',
    url: '/api/rb-oem/oem/mall/mallApi/masterOrderListExport',
    method: 'get',
    params
  })
}

/**
 * @物流查询
 * @desc {orderCode:订单号,subOrderCode:子订单号}
 */
export const apiWuLiu = (params) => {
  return request({
    url: '/api/rb-oem/oem/mall/mallApi/queryExpressInfo',
    method: 'get',
    params
  })
}


/* 主订单详情 */
export const apiDetail = (params) => {
  return request({
    url: '/api/rb-oem/oem/mall/mallApi/queryMasterOrderInfo',
    method: 'get',
    params
  })
}

/* 校验库存是否存在 改 SN */
export const apicheckSN= (row) => {
  return request({
    url: '/api/rb-oem/oem/mall/mallApi/checkDeliverGoods',
    method: 'post',
    data: row
  })
}

/* 发货 */
export const apiFaHuo= (row) => {
  return request({
    url: '/api/rb-oem/oem/mall/mallApi/deliverGoods',
    method: 'post',
    data: row
  })
}

/* 子订单--券--列表 */
export const apiCouponList = (current, size,params) => {
  return request({
    url: '/api/rb-oem/oem/mall/mallApi/queryMallCouponList',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  })
}

// 子主订单列表查询
export const apizList = (current, size,params) => {
  return request({
    url: '/api/rb-oem/oem/mall/mallApi/querySubOrderList',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  })
}

/* 子订单详情 */
export const apizDetail = (params) => {
  return request({
    url: '/api/rb-oem/oem/mall/mallApi/querySubOrderInfo',
    method: 'get',
    params
  })
}
/* 批量导入模板 */
export const getExportTemplate = (params) => {
  return request({
    headers: {
      "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
    },
    responseType: 'blob',
    url: '/api/rb-oem/oem/mall/mallApi/deliverExcelTemplate',
    method: 'get',
    params: {
      ...params
    }
  })
}

/* 批量入库 */
export const uploadFile = (file, type, param) => {
  const formData = new FormData();
  formData.append('file', file);
  formData.append('type', type);
  formData.append('expressCode', param.expressCode);
  formData.append('expressName', param.expressName);
  formData.append('subOrderCode', param.subOrderCode);
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: '/api/rb-oem/oem/mall/mallApi/deliverGoodsExcel',
    method: 'post',
    data: formData
  })
}

/* 发货 */
export const refundOrder= (row) => {
  return request({
    url: '/api/rb-oem/oem/mall/mallApi/refundOrder',
    method: 'post',
    data: row
  })
}